package aStar;

public class Tile {
	
	public int tileX = -1;
	public int tileY = -1;
	public int tileHight = 1;
	public double G;
	public double H;
	public double F;
	private Tile parent;
	private boolean walkable = true;
	
	public Tile(int tileX, int tileY, int tileHight) {
		this.tileX = tileX;
		this.tileY = tileY;
		this.tileHight = tileHight;
	}
	
	public Tile(int tileX, int tileY, int tileHight, double G, double H, double F) {
		this.tileX = tileX;
		this.tileY = tileY;
		this.tileHight = tileHight;
		this.G = G;
		this.H = H;
		this.F = F;
	}
	
	//an empty constructor ...
	//TODO: find an alternative
	public Tile() {	}
	
	//Setter for the parent tile
	public void setParent(Tile tile){
		this.parent = tile;
	}
	
	public void setWalkable(boolean walkable) {
		this.walkable = walkable;
	}
	
	//getter for the parent tile
	public Tile getParent(){
		return parent;
	}
	
	//Returns a formated string of the coordinates of the tile
	public String getCoordinate(boolean inString) {
		if (inString) {
			return (""+tileX+","+tileY+","+tileHight);
		} else {
			return null;
		}
	}
	
	public boolean isWalkable() {
		return walkable;
	}
	
	//Calculate F for the tiles G and H values
	public void calcF(){
		F = G + H;
	}
	
	//Calculate F for given G and H values
	public void calcF(double G, double H){
		this.F = G + H;
	}
	
	//Generate info over the tile when converted to string
	public String toString(){
		return ("<TILE> ["+getCoordinate(true)+" / "+G+","+H+","+F+" with parent "+parent.getCoordinate(true)+"]");
	}
}
